{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"https://raw.githubusercontent.com/Qiskit/qiskit-tutorials/master/images/qiskit-heading.png\" alt=\"Note: In order for images to show up in this jupyter notebook you need to select File => Trusted Notebook\" width=\"500 px\" align=\"left\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# W state in multi-qubit systems\n",
    "\n",
    "The latest version of this notebook is available on https://github.com/qiskit/qiskit-tutorial.\n",
    "\n",
    "For more information about how to use the IBM Q experience (QX), consult the [tutorials](https://quantumexperience.ng.bluemix.net/qstage/#/tutorial?sectionId=c59b3710b928891a1420190148a72cce&pageIndex=0), or check out the [community](https://quantumexperience.ng.bluemix.net/qstage/#/community).\n",
    "\n",
    "***\n",
    "## Contributors\n",
    "\n",
    "Pierre Decoodt, Université Libre de Bruxelles"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\decpi\\Anaconda3\\envs\\q7env\\lib\\site-packages\\marshmallow\\schema.py:364: ChangedInMarshmallow3Warning: strict=False is not recommended. In marshmallow 3.0, schemas will always be strict. See https://marshmallow.readthedocs.io/en/latest/upgrading.html#schemas-are-always-strict\n",
      "  ChangedInMarshmallow3Warning\n"
     ]
    }
   ],
   "source": [
    "# useful additional packages \n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import numpy as np\n",
    "import time\n",
    "from pprint import pprint\n",
    "\n",
    "# importing Qiskit\n",
    "from qiskit import Aer, IBMQ\n",
    "from qiskit.providers.ibmq import least_busy \n",
    "from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute\n",
    "\n",
    "# import basic plot tools\n",
    "from qiskit.tools.visualization import plot_histogram"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "IBMQ.load_account()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Theoretical background\n",
    "\n",
    "In addition to the GHZ states, the generalized W states, as proposed by Dür, Vidal and Cirac, in 2000, is a class of interesting examples of multiple qubit entanglement.\n",
    "\n",
    "A generalized $n$ qubit W state can be written as :\n",
    "$$ |W_{n}\\rangle \\; = \\; \\sqrt{\\frac{1}{n}} \\: (\\:|10...0\\rangle \\: +  |01...0\\rangle \\: +...+ |00...1\\rangle \\:) $$\n",
    "\n",
    "Here are presented circuits allowing to deterministically produce respectively a three, a four and a five qubit W state.\n",
    "\n",
    "A 2016 paper by Firat Diker proposes an algorithm in the form of nested boxes allowing the deterministic construction of W states of any size $n$. The experimental setup proposed by the author is essentially an optical assembly including half-wave plates. The setup includes $n-1$ so-called two-qubit $F$ gates (not to be confounded with the Fredkin's three-qubit gate).\n",
    "\n",
    "It is possible to construct the equivalent of such a $F$ gate on a superconducting quantum computing system using transmon qubits in ground and excited states. A $F_{k,\\, k+1}$ gate with control qubit $q_{k}$ and target qubit $q_{k+1}$ is obtained here by:\n",
    "\n",
    " - First a rotation round Y-axis $R_{y}(-\\theta_{k})$ applied on $q_{k+1}$\n",
    " - Then a controlled Z-gate $cZ$ in any direction between the two qubits $q_{k}$ and $q_{k+1}$\n",
    " - Finally a rotation round Y-axis $R_{y}(\\theta_{k})$ applied on $q_{k+1}$\n",
    " \n",
    "The matrix representations of a $R_{y}(\\theta)$ rotation and of the $cZ$ gate can be found in the \"Quantum gates and linear algebra\" Jupyter notebook of the Qiskit tutorial. \n",
    "\n",
    "The value of $\\theta_{k}$ depends on $n$ and $k$ following the relationship:\n",
    "\n",
    "$$\\theta_{k} = \\arccos \\left(\\sqrt{\\frac{1}{n-k+1}}\\right) $$\n",
    "\n",
    "Note that this formula for $\\theta$ is different from the one mentioned in the Diker's paper. This is due to the fact that we use here Y-axis rotation matrices instead of $W$ optical gates composed of half-wave plates.\n",
    "\n",
    "At the beginning, the qubits are placed in the state:  $|\\varphi_{0} \\rangle \\, = \\, |10...0 \\rangle$.\n",
    "\n",
    "This is followed by the application of $n-1$ sucessive $F$ gates. \n",
    "\n",
    "$$|\\varphi_{1}\\rangle = F_{n-1,\\,n}\\, ... \\, F_{k,\\, k+1}\\, ... \\, F_{2,\\, 3}  \\,F_{1,\\, 2}\\,|\\varphi_{0} \\rangle \\,= \\; \\sqrt{\\frac{1}{n}} \\: (\\:|10...0\\rangle \\: +  |11...0\\rangle \\: +...+ |11...1\\rangle \\:) $$\n",
    "\n",
    "Then, $n-1$ $cNOT$ gates are applied. The final circuit is: \n",
    "\n",
    "$$|W_{n}\\rangle \\,= cNOT_{n,\\, n-1}\\, cNOT_{n-1,\\, n-2}...cNOT_{k,\\, k-1}...cNOT_{2,\\, 1}\\,\\,|\\varphi_{1} \\rangle$$\n",
    "\n",
    "Let's launch now in the adventure of producing deterministically W states, on simulator or in the real world!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now you will have the opportunity to choose your backend.\n",
    "\n",
    "(If you run the following cells in sequence, you will end with the local simulator, which is a good choice for a first trial)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Your choice for the backend is:  qasm_simulator flag_qx2 is:  True\n"
     ]
    }
   ],
   "source": [
    "\"Choice of the backend\"\n",
    "# using local qasm simulator\n",
    "backend = Aer.get_backend('qasm_simulator')  \n",
    "\n",
    "# using IBMQ qasm simulator \n",
    "# backend = IBMQ.get_backend('ibmq_qasm_simulator')\n",
    "# using real device\n",
    "# backend = least_busy(IBMQ.backends(simulator=False))\n",
    "\n",
    "flag_qx2 = True\n",
    "if backend.name() == 'ibmqx4':\n",
    "        flag_qx2 = False\n",
    "        \n",
    "print(\"Your choice for the backend is: \", backend, \"flag_qx2 is: \", flag_qx2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Here, two useful routine\n",
    "# Define a F_gate\n",
    "def F_gate(circ,q,i,j,n,k) :\n",
    "    theta = np.arccos(np.sqrt(1/(n-k+1)))\n",
    "    circ.ry(-theta,q[j])       \n",
    "    circ.cz(q[i],q[j])\n",
    "    circ.ry(theta,q[j])\n",
    "    circ.barrier(q[i])\n",
    "# Define the cxrv gate which uses reverse CNOT instead of CNOT\n",
    "def  cxrv(circ,q,i,j) :\n",
    "    circ.h(q[i])\n",
    "    circ.h(q[j])\n",
    "    circ.cx(q[j],q[i])\n",
    "    circ.h(q[i])\n",
    "    circ.h(q[j])\n",
    "    circ.barrier(q[i],q[j])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Three-qubit W state, step 1\n",
    "\n",
    "In this section, the production of a three qubit W state will be examined step by step.\n",
    "\n",
    "In this circuit, the starting state is now: $ |\\varphi_{0} \\rangle \\, = \\, |100\\rangle$.\n",
    "\n",
    "The entire circuit corresponds to:                                 \n",
    "                \n",
    "$$ |W_{3}\\rangle \\,=\\,  cNOT_{3,2}\\,  \\, cNOT_{2,1}\\,  \\, F_{2,3} \\, \n",
    "\\, F_{1,2} \\,  \\, |\\varphi_{0} \\rangle \\, $$    \n",
    "\n",
    "Run the following cell to see what happens when we first apply $F_{1,2}$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start W state 3-qubit (step 1) on qasm_simulator N= 1024 08/01/2019 17:39:52\n",
      "end   W state 3-qubit (step 1) on qasm_simulator N= 1024 08/01/2019 17:39:52\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAccAAAFGCAYAAAAfEFTPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAA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5zHzv3n5fY2NjOltVktReTU3NvMw8ZV/9KjlyfAVoA4ozTd/M60eTO30ceDYzP1t+/suIeBV4MiL+OjN/0zOlSpL6sop955iZrcA8YEZh0wxKs1Y7MoRSoLa383l0X3WSJP1epRcBuA24PyKepTTZ5mqgHrgLICLuA2h3yvR7wN0RcQ2/P616OzA/M1dUuHZJUh9R0XDMzG9GxCjgk5SCbjFwYWbuXLFgbKH/VyNiGPAh4FZgI/ATYFblqpYk9TUVXz4uM+8E7tzDtnM6aPsCpWsbJUmqCO/KIUlSgeEoSVKB4ShJUoHhKElSgeEoSVKB4ShJUoHhKElSgeEoSVKB4ShJUoHhKElSgeEoSVKB4ShJUoHhKEkHgMcee4xTTz2Vk08+mdtvv73DPg899BDTpk3j9NNP54Mf/OCu9htuuIHTTz+d0047jY997GNkJlu2bOGyyy7jtNNO4/TTT+emm26q1FvpFSp+Vw5J0u7a2tqYNWsWDz74IPX19Zx77rmcf/75HH/88bv6LFu2jNtvv50f/ehHjBgxgrVr1wLwzDPP8Mwzz/DUU08BcMEFF/D0009z0kkn8aEPfYjp06fT2trKxRdfzI9//GNmzCjeb14dceQoSVU2b948jj76aMaPH8/AgQOZOXMmjzzyyG597rvvPj7wgQ8wYsQIAGprawGICLZt20Zrayvbtm1jx44d1NbWMmTIEKZPnw7AwIEDectb3sLq1asr+8YOYoajJFVZS0sLRx555K7n9fX1tLS07NZn2bJlLFu2jPPPP58ZM2bw2GOPAXDqqady1lln0dDQQENDA29729uYNGnSbvtu3LiRRx99lLe+9a09/2Z6CU+rSlKVZebr2iJit+c7duygubmZ733ve6xevZoLL7yQuXPnsm7dOn7961+zePFiAGbOnMncuXM544wzdu135ZVXctVVVzF+/Pgefy+9hSNHSaqy+vp6Vq1atev56tWrOeKII17X54ILLmDAgAGMGzeOY489lmXLlvH973+fU045hUMPPZRDDz2U8847j1/84he79vvIRz7CMcccwzXXXFOx99MbGI6SVGUnnXQSzc3NLF++nNbWVh588EHOP//83fpceOGFuybdrFu3jq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24pJx0gPgLYAFwV0S8MyKO2HkZB5SusYqI4RFxQTlItZ8cOfZB5WsbH8rM2wrt/ShdH/UVYFlmnl+N+iTtLiJ+CrwG9AfOoLRc3EPAg5SWedwYEVcD78vMadWrtPc4Z2KrAAACTklEQVRw5NjHRER/SiPES3aODiOiX0T0K18z9QRwNTAmIqZWs1ZJUD5OtwN3Z+Z0YBylf8D+Z0pLPM6JiI8CH8HLN7qN4djHlFe/uZfSWox/FRGjd15I3K7br4HxlC7rkFRd/SmNEtcBZObKzPzbzDyO0lJxPwNmUVqs45aqVdnLeFq1jynPUn0TpTUYb6Z04H0b+CbwG+AtlL53bMjMP6xWnZJ+r7xiVWbma+3v27hzEk5EfJrSHILGatXY2xiOfVhEjADeR2lCzh8Am4FtwLPAZzLTUzTSAWJPM1IjYggwH7gnM/+u8pX1ToZjHxIRw4HN7Q+w8kjyEOBQSqtrvGooSgeGjo7ZDvocAlwGfKPdEnLaT4ZjHxIR/0hpVPgspeulNnXQZ6Q3OJYODJ08Zkdk5r9XvLheznDsIyLicuDrwCZKNzL+MaXV/X8JrMrMrRFxKKWlp/4mMxdVrVhJezpmf0TpmF1dPmYHA/8M/HVmLq5asb2Q4dhHRMTdQBul2WwzgSuAY4AmSncV/1dKCwPckZkD9/Q6kirDY7a6DMc+oHxt4yxgeGZ+rF37FOCDwKWUvnccAdybmR+oSqGSAI/ZA4Hh2EdExEhgdGb+qnxT1O2FiTmXAd8ATsrM56pVp6QSj9nq6l/tAlQZmbkB2FB+3Aq7ZqpGeQGA4cBrHmTSgcFjtroMxz6ssKj4MOCGatUiad88ZivH06oCdt0Sp827cEgHB4/ZnmU4SpJU4MLjkiQVGI6SJBUYjpIkFRiOkiQVGI6SJBUYjpIkFfx/a38uJnWN5VUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3-qubit W state Step 1\n",
    "n = 3\n",
    "q = QuantumRegister(n)\n",
    "c = ClassicalRegister(n)\n",
    "W_states = QuantumCircuit(q,c) \n",
    "\n",
    "W_states.x(q[2]) #start is |100>\n",
    "F_gate(W_states,q,2,1,3,1) # Applying F12\n",
    "    \n",
    "for i in range(3) :\n",
    "    W_states.measure(q[i] , c[i]) \n",
    "\n",
    "# circuits = ['W_states']\n",
    "\n",
    "shots = 1024\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('start W state 3-qubit (step 1) on', backend, \"N=\", shots,time_exp)\n",
    "result = execute(W_states, backend=backend, shots=shots)\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('end   W state 3-qubit (step 1) on', backend, \"N=\", shots,time_exp)\n",
    "plot_histogram(result.result().get_counts(W_states))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Three-qubit W state: adding step 2\n",
    "\n",
    "In the previous step you obtained an histogram compatible with the following state:\n",
    "\n",
    "$$ |\\varphi_{1} \\rangle= F_{1,2}\\,  |\\varphi_{0} \\rangle\\,=F_{1,2}\\,  \\,|1 0 0 \\rangle=\\frac{1}{\\sqrt{3}} \\: |1 0 0 \\rangle \\: + \\sqrt{\\frac{2}{3}} \\: |1 1 0 \\rangle $$\n",
    "\n",
    "NB: Depending on the backend, it happens that the order of the qubits is modified, but without consequence for the state finally reached.\n",
    "\n",
    "We seem far from the ultimate goal.\n",
    "\n",
    "Run the following circuit to obtain $|\\varphi_{2} \\rangle =F_{2,3}\\, \\, |\\varphi_{1} \\rangle$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start W state 3-qubit (steps 1 + 2) on qasm_simulator N= 1024 08/01/2019 17:40:00\n",
      "end   W state 3-qubit (steps 1 + 2) on qasm_simulator N= 1024 08/01/2019 17:40:00\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw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JVU2w32hu2m+4xHGtERAwHRmXmr8tDNG0rdMz5GPA94KTM/FW16lRtsd1ob9hu9sxbOWpEZq4D1pUfb4WdPVUjM9uBYcBrB2pDVedsN9obtps9MxxrWGFQ8aHA9dWqRX2H7UZ7w3azK0+r9hHlWRTanYVDPWG70d6w3RiOkiS9ibNySJJUYDhKklRgOEqSVGA4SpJUYDhKklRgOEqSVPD/AUcFJNSCbwTEAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3-qubit W state, first and second steps\n",
    "n = 3\n",
    "q = QuantumRegister(n) \n",
    "c = ClassicalRegister(n)\n",
    "W_states = QuantumCircuit(q,c) \n",
    "        \n",
    "W_states.x(q[2]) #start is |100>\n",
    "F_gate(W_states,q,2,1,3,1) # Applying F12\n",
    "F_gate(W_states,q,1,0,3,2) # Applying F23\n",
    "       \n",
    "for i in range(3) :\n",
    "    W_states.measure(q[i] , c[i]) \n",
    "\n",
    "shots = 1024\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('start W state 3-qubit (steps 1 + 2) on', backend, \"N=\", shots,time_exp)\n",
    "result = execute(W_states, backend=backend, shots=shots)\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('end   W state 3-qubit (steps 1 + 2) on', backend, \"N=\", shots,time_exp)\n",
    "plot_histogram(result.result().get_counts(W_states))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Three-qubit W state, full circuit\n",
    "\n",
    "In the previous step, we got an histogram compatible with the state:\n",
    "\n",
    "$$ |\\varphi_{2} \\rangle =F_{2,3}\\,  \\, |\\varphi_{1} \\rangle=F_{2,3}\\,  \\, (\\frac{1}{\\sqrt{3}} \\: |1 0 0 \\rangle \\: + \\sqrt{\\frac{2}{3}} \\: |1 1 0 )= \\frac{1}{\\sqrt{3}} \\: (|1 0 0 \\rangle \\: +  |1 1 0 \\:\\rangle +  |1 1 1\\rangle) $$\n",
    "\n",
    "NB: Again, depending on the backend, it happens that the order of the qubits is modified, but without consequence for the state finally reached.\n",
    "\n",
    "It looks like we are nearing the goal.\n",
    "\n",
    "Indeed, two $cNOT$ gates will make it possible to create a W state.\n",
    "\n",
    "Run the following cell to see what happens. Did we succeed?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start W state 3-qubit on qasm_simulator N= 1024 08/01/2019 17:40:04\n",
      "end   W state 3-qubit on qasm_simulator N= 1024 08/01/2019 17:40:04\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAccAAAFGCAYAAAAfEFTPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3X2cVvV95//XxxGIGFAGR2WCgAiLIyAZ72K0MRJComlTI9rc/NxNTGNc426yWXc33e0ag/0lpvXeXyOxwWyi0TQ2SquNoWUNRpMYEwuEyo0EHMEiI0GkYAUZGT+/P84FDkdGZmTmuobh9Xw85sF1nfM9M59rrsO8r3PO93y/kZlIkqTXHVTrAiRJ6msMR0mSSgxHSZJKDEdJkkoMR0mSSgxHSZJKDEdJkkoMR0mSSgxHSZJKDq51Ab1l+PDhOWrUqFqXIUnqQ37zm9+8kJkNe2vXb8Nx1KhRzJ8/v9ZlSJL6kPr6+jVdaedpVUmSSgxHSZJKDEdJkkoMR0mSSgxHSZJKDEdJkkoMR0mSSgxHSZJKDEdJkkoMR0mSSgxHSZJKDEdJkkoMR0mSSgxHSZJKDEdJkkoMR0mSSgxHSZJKDEdJkkoMR0mSSqoejhFxeUQ8ExGvRMSCiH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MYO5c+fuFo5Dhw7d9Xjr1q1EBAAnnnjiruVNTU288sorbN++nUGDBnH33Xfzq1/9CoCDDjqI4cOHV+HVSFL/YjjWSGtrK+94xzt2PW9sbGTBggVvaHf77bcza9Ys2trauP/++9+w/oEHHuDEE09k0KBBbN68GYBrrrmGX/ziF4wZM4Zrr72WI488svdeiCT1Q15zrJHMfMOynUeGHV1yySUsXLiQmTNncsMNN+y2bvny5Vx99dXceOONAOzYsYN169bxrne9i5/+9KeceuqpXHXVVb3zAiSpHzMca6SxsZHnnntu1/N169Zx9NFHd9p+xowZPPjgg7ueP/fcc3zyk59k1qxZHHvssQDU19czePBg/uAP/gCA8847j8WLF/fSK5Ck/stwrJGTTjqJlpYW1qxZQ1tbG3PmzOGcc87Zrc3TTz+96/G8efM47rjjANi8eTMf//jH+fKXv8zpp5++q01E8MEPfpCf//znADz66KNMmDChCq9GkvoXrznWyMEHH8y1117LhRdeSHt7OxdddBFNTU1cc801NDc3c+655zJ79mweeeQRBgwYwOGHH86tt94KwOzZs3nmmWe4/vrruf766wG47777aGhoYObMmVx22WX86Z/+KUcccQTf+MY3avkyJWm/FHu69tUfNDc35/z582tdhg5QDjzeOQceVy3V19cvyMxT9tbO06qSJJUYjpIklRiOkiSVGI6SJJUYjpJ0AHirEx0A3HTTTZx88smcdtpp/OQnPwFg5cqVnHXWWbu+Ro0axTe/+c2qvZ7e5q0cktTP7ctEB0899RRz5szhscce4/nnn+f888/niSeeYPz48btmBGpvb2fixIm7BiDpDzxylKR+ruNEBwMHDtw10UFHnU10MHfuXGbMmMGgQYMYPXo0xx577BvGgX7kkUcYM2YMxxxzTO+/mCrxyFGS+rl9meigtbWVU045ZbdtW1tbd9tuzpw5XHDBBb1UfW145ChJ/dy+THSwt23b2tr4h3/4B84777werLj2DEdJ6uf2ZaKDvW370EMPceKJJ/a7qfEMR0nq5/ZlooNzzjmHOXPmsH37dtasWUNLSwsnn3zyrrb33XdfvzulCl5z3CvHyOycY2RK+4d9meigqamJj3zk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7bNnbKzO3AHcC5tShOfdbe9ps23G/0Ru8DvgWcRNET/gyKUZV+CFwZEe+juI79ocx8smZV1pDh2EdUxsP83xSj39wJfDIijomIQwEiYjDwXop7kiTA/UbdV7m38RngXzOzJTOvz8zJwKnAI8CnKG4f+0sOwJv/d/KaYx9TGRXny8AfUoxt+EtgA8XYqq3AJQfqJzl1zv1G3VEZh/eozHyqMvrWq6WOOR8D/ho4KTN/U6s6a8lw7KMq3fN/H/gIxVBxS4AfZuZTNS1MfZr7jd6qyin5qMwD+lnglswcXOu6asVw3A8cSCPhq+e43+itiogrgLrMvK7WtdSK4ShJ2k1EDADaD+QPV4ajJEkl9laVJKnEcJQkqcRwlCSpxHCUJKnEcJQkqcRwlCSp5P8H3d89nZl92hcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3-qubit W state\n",
    "n = 3\n",
    "q = QuantumRegister(n) \n",
    "c = ClassicalRegister(n)\n",
    "\n",
    "W_states = QuantumCircuit(q,c) \n",
    "\n",
    "W_states.x(q[2]) #start is |100>\n",
    "F_gate(W_states,q,2,1,3,1) # Applying F12\n",
    "F_gate(W_states,q,1,0,3,2) # Applying F23\n",
    "\n",
    "if flag_qx2 : # option ibmqx2 \n",
    "    W_states.cx(q[1],q[2]) # cNOT 21\n",
    "    W_states.cx(q[0],q[1]) # cNOT 32\n",
    "    \n",
    "else :        # option ibmqx4  \n",
    "    cxrv(W_states,q,1,2)\n",
    "    cxrv(W_states,q,0,1)\n",
    "\n",
    "for i in range(3) :\n",
    "    W_states.measure(q[i] , c[i]) \n",
    "\n",
    "shots = 1024\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('start W state 3-qubit on', backend, \"N=\", shots,time_exp)\n",
    "result = execute(W_states, backend=backend, shots=shots)\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('end   W state 3-qubit on', backend, \"N=\", shots,time_exp)\n",
    "plot_histogram(result.result().get_counts(W_states))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now you get an histogram compatible with the final state $|W_{3}\\rangle$ through the following steps:\n",
    "\n",
    "$$ |\\varphi_{3} \\rangle =  cNOT_{2,1}\\,  \\, |\\varphi_{2} \\rangle =cNOT_{2,1}\\,\\frac{1}{\\sqrt{3}} \\: (|1 0 0 \\rangle \\: +  |1 1 0 \\rangle\\: +  |1 1 1\\rangle)  =  \\frac{1}{\\sqrt{3}} \\: (|1 0 0 \\rangle \\: +  |0 1 0 \\: +  |0 1 1\\rangle) $$\n",
    "\n",
    "$$ |W_{3} \\rangle =  cNOT_{3,2}\\, \\, |\\varphi_{3} \\rangle =cNOT_{3,2}\\,\\frac{1}{\\sqrt{3}} \\: (|1 0 0 \\rangle \\: +  |010 \\: \\rangle+  |0 1 1\\rangle)  =  \\frac{1}{\\sqrt{3}} \\: (|1 0 0 \\rangle \\: +  |0 1 0 \\: +  |0 0 1\\rangle) $$\n",
    "\n",
    "Bingo!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Four-qubit W state\n",
    "\n",
    "In this section, the production of a four-qubit W state will be obtained by extending the previous circuit.\n",
    "\n",
    "In this circuit, the starting state is now: $ |\\varphi_{0} \\rangle \\, = \\, |1000\\rangle$.\n",
    "\n",
    "A $F$ gate was added at the beginning of the circuit and a $cNOT$ gate was added before the measurement phase.\n",
    "\n",
    "The entire circuit corresponds to:\n",
    "\n",
    "$$ |W_{4}\\rangle \\,=\\, cNOT_{4,3}\\,  \\, cNOT_{3,2}\\,  \\, cNOT_{2,1}\\,  \\, F_{3,4} \\, \\, F_{2,3} \\,  \\, F_{1,2} \\,  \\,|\\varphi_{0} \\rangle \\, $$  \n",
    "\n",
    "Run the following circuit and see what happens."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start W state 4-qubit  qasm_simulator N= 1024 08/01/2019 17:40:07\n",
      "end   W state 4-qubit on qasm_simulator N= 1024 08/01/2019 17:40:07\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdAAAAFOCAYAAAA2MUwzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3X181XXdx/HXh3EjQ0AHC0eISNAEQ5ygoAGCSqKWGHVpat50Z6gXyUVddkUiUmllkaKhppfkLSUqXhplEaIiRmCAgIEoISBsKiB3gjoYn+uP72/rbGyw89t2ztnO+/l47ME5v9/3nH1+fLd9zu97a+6OiIiIJKdZugMQERFpjJRARUREYlACFRERiUEJVEREJAYlUBERkRiUQEVERGJQAhUREYlBCVRERCQGJVAREZEYmqc7gHTq0KGDd+3aNd1hiIhIBnn11Ve3uHv+ocpldQLt2rUrc+fOTXcYIiKSQfLy8tbXppyacEVERGJQAhUREYlBCVRERCQGJVAREZEYlEBFRERiUAIVERGJQQlUREQkBiVQERGRGJRARUREYlACFRERiUEJVEREJAYlUBERkRiUQEVERGJQAhUREYlBCVRERCQGJVAREZEYlEBFRERiUAIVERGJQQlUREQkBiVQERGRGJRARUREYlACFRERiUEJVEREJAYlUBHJaHPmzOGUU06hX79+3H777Qecnzp1KgMHDmTQoEFccMEFvP322xXnNm7cyKhRoxgwYAADBw5kw4YNAFx77bWceOKJDBkyhCFDhrBixYqUXY80Hc3THYCISE3Kysq4/vrrmTlzJp07d+bMM89kxIgRHHfccRVlTjjhBObOnUtubi7Tpk1j4sSJTJs2DYCrr76acePGMWzYMD744AOaNfv3PcOkSZMYOXJkyq9Jmg7dgYpIxlq8eDHHHnss3bp1o2XLlowaNYpnn322UpnBgweTm5sLQP/+/SkuLgbg9ddfZ9++fQwbNgyAww8/vKKcSH1QAhWRjFVSUsInP/nJiuedO3empKSkxvKPPPIIZ511FgD/+te/aN++PZdffjmnn346N954I2VlZRVlb775ZgYNGsT48eP5+OOPG+4ipMlSAhWRjOXuBxwzs2rLzpgxg6VLlzJmzBgA9u3bx4IFC/jRj37Ec889x7p165g+fToAEyZMYOHChTz33HNs376dKVOmNNxFSJOlBCoiGatz585s2rSp4nlxcTFHHXXUAeVeeOEFJk+ezPTp02nVqlXFa0844QS6detG8+bNOe+881i+fDkARx11FGZGq1atuOSSS1iyZElqLkiaFCVQEclYJ510EmvXrmX9+vWUlpYyc+ZMRowYUanM8uXLGTduHNOnTyc/P7/Sa7dv386WLVsAmDdvHoWFhQC88847QLjD/eMf/0ivXr1SdEVNQ11GRnfs2LFi9PMll1xScfzFF19k6NChDBkyhHPOOYe1a9em5FrqwqprIskWRUVFPnfu3HSHISIH8de//pXx48dTVlbGpZdeyne/+11uueUWioqKOOecc/jiF7/IypUr6dSpEwBdunSpaKp9/vnnmTBhAu7OiSeeyG233UbLli0ZOXIkW7Zswd3p06cPkydP5vDDD0/nZTYaZWVlnHzyyZVGRt93332VRka/9NJL9OvXr2Jk9Pz58ytGRh999NGVEmq5k08+mUceeYTCwkLuv/9+lixZwtSpU1N2XYny8vIWu3v/Q5XTNBYRyWjDhw9n+PDhlY6NHz++4vFTTz1V42uHDRvG/PnzDzj+9NNP11+AWSZxZDRQMTI6MYEOHjy44nH//v2ZMWPGId/XzNi1axcAO3furLapPtMogYqISK1VNzJ68eLFNZZPHBkN8NFHH3HGGWeQk5PD2LFjOe+88wCYMmUKF110EYcddhht27Zl9uzZDXcR9UQJVEREai3OyOhZs2ZVHFu+fDkFBQWsW7eOkSNH0rt3b4499ljuvvtuHnvsMfr3788dd9zBDTfcwB133NFg11EfNIhIRERqrS4jowEKCgoA6NatG4MGDWL58uVs2bKF1157jf79Q7fjqFGjWLRoUQNfSd0p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sl1UlmqqleNrj744QpLbtQvaSUmV1M+PAymbCA/y/MbJSZ9SjfeSVap/i3ZtanKSVPUAJNt7WEJsHbzKxn+fSIcu7+MfAgcE46gstSqpPMdKh6KUX1kg5nAPcCJxFGqJ9GWB3qceAGMzuD0G99rruvSFuUDUQJNI2itTx/SFgz8iHgcjM72szaAJhZLnA6YX6VpIDqJDOpXjJPNPfzLWC7u69191+6ex/CqkMvAlcQpn7dSRNbQKGc+kAzQLTSzQTgfMK6kQuAzYR1V0sIS2M1uU9vmUx1kplUL5klWpe4k7u/Hq3StbfKYKKLgN8BJ7n7q+mKs6EogWaQaJj+ecAFhCXiXgMed/fX0xpYFlOdZCbVS+aKmtfNwz6t3wKmuHtuuuNqCEqgGaqp7FbQlKhOMpPqJXOZ2Tggx91/ke5YGoISqIiINAgzawGUNdUPOEqgIiIiMWgUroiISAxKoCIiIjEogYqIiMSgBCoiIhKDEqiIiEgMSqAiIiIx/D9DezkAvEOyrQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 4-qubit W state\n",
    "n = 4\n",
    "q = QuantumRegister(n) \n",
    "c = ClassicalRegister(n)\n",
    "W_states = QuantumCircuit(q,c) \n",
    "\n",
    "W_states.x(q[3]) #start is |1000>\n",
    "F_gate(W_states,q,3,2,4,1) # Applying F12\n",
    "F_gate(W_states,q,2,1,4,2) # Applying F23\n",
    "F_gate(W_states,q,1,0,4,3) # Applying F34        \n",
    "cxrv(W_states,q,2,3) # cNOT 21\n",
    "if flag_qx2 : # option ibmqx2  \n",
    "    W_states.cx(q[1],q[2]) # cNOT 32\n",
    "    W_states.cx(q[0],q[1]) # cNOT 43\n",
    "\n",
    "else :        # option ibmqx4 \n",
    "    cxrv(W_states,q,1,2)\n",
    "    cxrv(W_states,q,0,1)\n",
    "\n",
    "for i in range(4) :\n",
    "    W_states.measure(q[i] , c[i]) \n",
    "\n",
    "# circuits = ['W_states']\n",
    "\n",
    "shots = 1024\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('start W state 4-qubit ', backend, \"N=\", shots,time_exp)\n",
    "result = execute(W_states, backend=backend, shots=shots)\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('end   W state 4-qubit on', backend, \"N=\", shots,time_exp)\n",
    "plot_histogram(result.result().get_counts(W_states))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, if you used a simulator, you get an histogram clearly compatible with the state:\n",
    "\n",
    "$$ |W_{4}\\rangle \\;=\\; \\frac{1}{2} \\: (\\:|1000\\rangle  +  |0100\\rangle  + |0010\\rangle + |0001\\rangle \\:) $$\n",
    "\n",
    "If you used a real quantum computer, the columns of the histogram compatible with a $|W_{4}\\rangle$ state are not all among the highest one. Errors are spreading..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Five-qubit W state\n",
    "\n",
    "In this section, a five-qubit W state will be obtained, again by extending the previous circuit.\n",
    "\n",
    "In this circuit, the starting state is now: $ |\\varphi_{0} \\rangle  =  |10000\\rangle$.\n",
    "\n",
    "A $F$ gate was added at the beginning of the circuit and an additionnal $cNOT$ gate was added before the measurement phase.\n",
    "\n",
    "$$ |W_{5}\\rangle = cNOT_{5,4}   cNOT_{4,3}   cNOT_{3,2}   cNOT_{2,1}  F_{4,5}   F_{3,4}   F_{2,3}    F_{1,2}   |\\varphi_{0} \\rangle  $$\n",
    "\n",
    "Run the following cell and see what happens."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start W state 5-qubit on qasm_simulator N= 1024 08/01/2019 17:40:10\n",
      "end   W state 5-qubit on qasm_simulator N= 1024 08/01/2019 17:40:10\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhE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iZdQI2pP4gS85I2xImOzmGcEbf7N97SqBNLPmVugE4M2k4r97WnTCl1RWEWXTOd/dZWatoDlLs4il28eqJ3RGE2XO+T1gG7kLFbndm9gDh7PI9YLG7r6+lTGd3X9vcx2yrE1HT60tYfX3nuoEeLHb3pwntAJ+jpbdqo9jFU+zi1RW7Je7+LGFIywYUu92Y2YWEHxh3ECbZv93MzjGzoyxZecXCXML/z8z6N+fkCUqgmVBGuFx2l5n1rh46UC3p6TcBOCMblctxil08xS7enmJXiWJXl+HAg8BAQg/mrxFmcHoW+JmZDSe0LZ/p7h9krZaNRAm0iXmYQ/OnhHkgHwUuMbMjzOxAADNrD5xKGDMlKRS7eIpdPMUuTjL28xPgc3cvc/dfu3t/wqxDbwKXEoZK/ZZmPoFCNbWBZkgyC8y/Ad8hzAX5LrCSMCdpBWG6q2b/i6wpKHbxFLt4il36LMwd3NXdP0xmu9pWozPRBcBTwEB3/2u26tlYlEAzLOke/y3gLML0aXOBZ939w6xWrBlQ7OIpdvEUu72TXAI3D2upfh+4x93bZ7tejUEJNIusma5AkAsUu3iKXTzFbu+Y2Tighbvfnu26NAYlUBERyQgzawVU7Ss/QpRARUREIqgXroiISAQlUBERkQhKoCIiIhGUQEVERCIogYqIiERQAhUREYnw/wGuwwoRKxV2cgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 5-qubit W state\n",
    "n = 5\n",
    "q = QuantumRegister(n) \n",
    "c = ClassicalRegister(n)\n",
    "W_states = QuantumCircuit(q,c) \n",
    "\n",
    "W_states.x(q[4]) #start is |10000>\n",
    "F_gate(W_states,q,4,3,5,1) # Applying F12\n",
    "F_gate(W_states,q,3,2,5,2) # Applying F23\n",
    "F_gate(W_states,q,2,1,5,3) # Applying F34\n",
    "F_gate(W_states,q,1,0,5,4) # Applying F45\n",
    "W_states.cx(q[3],q[4]) # cNOT 21\n",
    "cxrv(W_states,q,2,3)   # cNOT 32\n",
    "if flag_qx2 : # option ibmqx2 \n",
    "    W_states.cx(q[1],q[2]) # cNOT 43\n",
    "    W_states.cx(q[0],q[1]) # cNOT 54\n",
    "    \n",
    "else :        # option ibmqx4 \n",
    "    cxrv(W_states,q,1,2)\n",
    "    cxrv(W_states,q,0,1)     \n",
    "    \n",
    "for i in range(5) :\n",
    "    W_states.measure(q[i] , c[i]) \n",
    "\n",
    "shots = 1024\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('start W state 5-qubit on', backend, \"N=\", shots,time_exp)\n",
    "result = execute(W_states, backend=backend, shots=shots)\n",
    "time_exp = time.strftime('%d/%m/%Y %H:%M:%S')\n",
    "print('end   W state 5-qubit on', backend, \"N=\", shots,time_exp)\n",
    "plot_histogram(result.result().get_counts(W_states))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, if you used the simulator, you see an histogram compatible with the state:\n",
    "\n",
    "$$|W_{5}\\rangle=\\frac{1}{\\sqrt{5}}\\:(\\:|10000\\rangle  +  |01000\\rangle  + |00100\\rangle +|00010\\rangle\\  +|00001\\rangle)$$\n",
    "\n",
    "But if you were running the program on one of the available real quantum computers, things are still less clear than in the previous case."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Conclusion:\n",
    "\n",
    "When the quantum computer simulator is used, the results accurately reflect the expected spectrum of frequency corresponding to a given $n$ value.\n",
    "\n",
    "For $n = 3$ on a real quantum computer, the results are obviously in accordance with W states.\n",
    "\n",
    "The errors amplify significantly for higher $n$ values, but the histogram shows the persistence of some frequency peaks compatible with W states creation.\n",
    "\n",
    "One cause of errors is the increasing number of gates. Even for an ideal quantum computer, where all the qubits are connected together bidirectionally, the number of elementary gates necessary for building the $F$ gates increases linearly with n, just like the number of late $cNOT$ in this model. Another cause of error is the interval between successive values of $\\theta_{k}$. Indeed these intervals decreases significantly for lower $k$ as $n$ increases.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Mathematical appendix :\n",
    "\n",
    "The operator allowing to deterministically obtain a n-qubit W state from the starting state $\\, |00...0 \\rangle$ can be coined a $W_{n}$ gate.\n",
    "\n",
    "For a three-qubit W state, the equation in Dirac notation is:\n",
    "\n",
    "$$W_{3}\\;\\, |000 \\rangle=\\sqrt{\\frac{1}{3}}(|100\\rangle + |010\\rangle + |001\\rangle)$$\n",
    "\n",
    "which becomes in matrix notation:\n",
    "\n",
    "$$\\begin{pmatrix}0 & 0 & 0 & 0 & \\;\\;1\\;\\; & 0 & 0 & 0\\\\\\sqrt{\\frac{1}{3}} & -\\sqrt{\\frac{1}{3}} & -\\sqrt{\\frac{1}{6}} & \\sqrt{\\frac{1}{6}} & 0 & 0 & 0 & 0\\\\\\sqrt{\\frac{1}{3}} & \\sqrt{\\frac{1}{3}} & -\\sqrt{\\frac{1}{6}} & -\\sqrt{\\frac{1}{6}} & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & \\;\\;1\\;\\; & 0 & 0\\\\\\sqrt{\\frac{1}{3}} & 0 & \\sqrt{\\frac{2}{3}}\n",
    " & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0 & \\sqrt{\\frac{1}{2}}\n",
    " & -\\sqrt{\\frac{1}{2}}\\\\0 & 0 & 0 & 0 & 0 & 0 & \\sqrt{\\frac{1}{2}} & \\sqrt{\\frac{1}{2}}\\\\0 & \\sqrt{\\frac{1}{3}} & 0 & \\sqrt{\\frac{2}{3}}\n",
    " & 0 & 0 & 0 & 0\\end{pmatrix} \\;\n",
    " \\begin{pmatrix}1\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\\\0\\end{pmatrix} = \n",
    " \\begin{pmatrix}0\\\\\\sqrt{\\frac{1}{3}}\\\\\\sqrt{\\frac{1}{3}}\\\\0\\\\\\sqrt{\\frac{1}{3}}\\\\0\\\\0\\\\0\\end{pmatrix}$$\n",
    " \n",
    " One can easily verify that:\n",
    " \n",
    " $$W_{3}^{\\dagger}W_{3} = I$$\n",
    " \n",
    " and that there is reversibility:\n",
    " \n",
    " $$W_{3}^{\\dagger}\\;\\, \\sqrt{\\frac{1}{3}}(|100\\rangle + |010\\rangle + |001\\rangle) = |000 \\rangle$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
